<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%--
  Created by IntelliJ IDEA.
  User: Think
  Date: 2024/7/22
  Time: 下午9:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>首页</title>
</head>
<body>
Hello Sam<br/>
<%
    out.println("Your Ip Address is "+request.getRemoteHost());
%>
<p>
    今天的日期是：<%=Calendar.getInstance().get(Calendar.YEAR)+"-"+(Calendar.getInstance().get(Calendar.MONTH)+1)+"-"+Calendar.getInstance().get(Calendar.DAY_OF_MONTH)%>
</p>
<%! int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); %>
<%! int weeksday = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); %>
<% if (day > 15){ %>
<p>哦！下旬</p>
<% }else{ %>
<p>啊？上旬</p>
<% } %>
<p>今天是：
<%
    switch (weeksday){
        case Calendar.MONDAY:
            out.println("星期一");
            break;
        case Calendar.TUESDAY:
            out.println("星期二");
            break;
        case Calendar.WEDNESDAY:
            out.println("星期三");
            break;
        case Calendar.THURSDAY:
            out.println("星期四");
            break;
        case Calendar.FRIDAY:
            out.println("星期五");
            break;
        case Calendar.SATURDAY:
            out.println("星期六");
            break;
        default:
            out.println("星期天");
    }
%>
<%
        Date date = new Date();
        SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        out.println("<h2 align = \"center\">" +fm.format(date)+"</h2>");
        %>
</body>
</html>
